@import "./_themes.scss";
//遍历主题map
@mixin themeify {
  @each $theme-name, $theme-map in $themes {
    //!global 把局部变量强升为全局变量
    $theme-map: $theme-map !global;
    //判断html的data-theme的属性值  #{}是sass的插值表达式
    //& sass嵌套里的父容器标识   @content是混合器插槽，像vue的slot
    [data-theme="#{$theme-name}"] & {
      @content;
    }
  }
}

//声明一个根据Key获取颜色的function
@function themed($key) {
  @return map-get($theme-map, $key);
}



//获取背景颜色
@mixin bg_color($color) {
  @include themeify {
    background-color: themed($color);
  }
}

//获取字体颜色
@mixin font_color($color) {
  @include themeify {
    color: themed($color);
  }
}

//获取边框颜色
@mixin border_color($color,$direction:all) {
  @include themeify {
    @if $direction == left {
      border-left-color: themed($color);
    }@else if $direction == right {
      border-right-color: themed($color);
    }@else if $direction == top {
      border-top-color: themed($color);
    }@else if $direction == bottom {
      border-bottom-color: themed($color);
    }@else{
      border-color: themed($color);
    }
  }
}
//获取边框相关颜色，设置边框
@mixin set_border($color,$size:1px,$type:solid) {
  @include themeify {
    border:$size $type themed($color);
  }
}


//获取渐变背景颜色
@mixin gradient_bg_color($color1,$color2,$angle:90deg) {
  @include themeify {
    background-image: linear-gradient($angle, themed($color1), themed($color2));
  }
}

//获取边框相关颜色，设置某个方向的边框
@mixin set_one_border($color,$direction:left,$size:1px,$type:solid) {
  @include themeify {
    @if $direction == left {
      border-left:$size $type themed($color);
    }@else if $direction == right {
      border-right:$size $type themed($color);
    }@else if $direction == top {
      border-top:$size $type themed($color);
    }@else if $direction == bottom {
      border-bottom:$size $type themed($color);
    }@else{
      border-left:$size $type themed($color);
    }
  }
}
